<?php

namespace JLPay\Models\Openmerch\Query;

use JLPay\Models\BaseResponse;

/**
 * 商户主结算卡查询响应
 */
class MerchMasterSettCardQueryResponse extends BaseResponse
{
    protected string $merchNo = '';  // 商户号
    protected string $merchName = '';  // 商户名称
    protected string $settleType = '';  // 结算类型
    protected string $accountName = '';  // 户名 (需要解密)
    protected string $accountNo = '';  // 账号 (需要解密)
    protected string $bankCode = '';  // 开户银行编码
    protected string $bankBranchId = '';  // 开户支行编号
    protected string $bankBranchName = '';  // 开户支行名称

    /**
     * 构造函数
     *
     * @param array|null $responseArray
     */
    public function __construct(?array $responseArray = null)
    {
        parent::__construct($responseArray);
        
        if ($responseArray) {
            $this->merchNo = $responseArray['merch_no'] ?? '';
            $this->merchName = $responseArray['merch_name'] ?? '';
            $this->settleType = $responseArray['settle_type'] ?? '';
            $this->accountName = $responseArray['account_name'] ?? '';
            $this->accountNo = $responseArray['account_no'] ?? '';
            $this->bankCode = $responseArray['bank_code'] ?? '';
            $this->bankBranchId = $responseArray['bank_branch_id'] ?? '';
            $this->bankBranchName = $responseArray['bank_branch_name'] ?? '';
        }
    }

    /**
     * 获取需要解密的敏感字段列表
     *
     * @return array
     */
    public function getSensitiveFields(): array
    {
        return [
            'account_name',  // 户名
            'account_no',    // 账号
        ];
    }

    /**
     * 获取商户号
     *
     * @return string
     */
    public function getMerchNo(): string
    {
        return $this->merchNo;
    }

    /**
     * 获取商户名称
     *
     * @return string
     */
    public function getMerchName(): string
    {
        return $this->merchName;
    }

    /**
     * 获取结算类型
     *
     * @return string
     */
    public function getSettleType(): string
    {
        return $this->settleType;
    }

    /**
     * 获取户名
     *
     * @return string
     */
    public function getAccountName(): string
    {
        return $this->accountName;
    }

    /**
     * 获取账号
     *
     * @return string
     */
    public function getAccountNo(): string
    {
        return $this->accountNo;
    }

    /**
     * 获取开户银行编码
     *
     * @return string
     */
    public function getBankCode(): string
    {
        return $this->bankCode;
    }

    /**
     * 获取开户支行编号
     *
     * @return string
     */
    public function getBankBranchId(): string
    {
        return $this->bankBranchId;
    }

    /**
     * 获取开户支行名称
     *
     * @return string
     */
    public function getBankBranchName(): string
    {
        return $this->bankBranchName;
    }

    /**
     * 转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        $data['merch_no'] = $this->merchNo;
        $data['merch_name'] = $this->merchName;
        $data['settle_type'] = $this->settleType;
        $data['account_name'] = $this->accountName;
        $data['account_no'] = $this->accountNo;
        $data['bank_code'] = $this->bankCode;
        $data['bank_branch_id'] = $this->bankBranchId;
        $data['bank_branch_name'] = $this->bankBranchName;
        return $data;
    }
} 